package com.example.carapi.mapper;

import com.example.carapi.bean.CarModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarModelMapper {
    @Select("select *\n" +
            "from car_model\n" +
            "where id=#{id}")
    CarModel getOne(@Param("id") Long id);

    @Select("select *\n" +
            "from car_model")
    List<CarModel> getAll();

    @Insert("insert\n" +
            "into car_model\n" +
            "values(name=#{name}, series_id=#{series_id}, price=#{price}, description=#{description}, photo=#{photo}, release_date=#{release_date})")
    void insert(CarModel carModel);

    @Update("update car_model\n" +
            "set name=#{name}, series_id=#{series_id}, price=#{price}, description=#{description}, photo=#{photo}, release_date=#{release_date}}\n" +
            "where id=#{id}")
    void update(CarModel carModel);

    @Delete("delete\n" +
            "from car_model\n" +
            "where id=#{id}")
    void delete(@Param("id") Long id);
}
